package com.kaishengit.dao;


import java.sql.ResultSet;
import java.sql.SQLException;
import com.kaishengit.entity.Admin;
import com.kaishengit.util.DBHelp;
import com.kaishengit.util.RowMapper;

public class AdminDao {
	
	private DBHelp<Admin> db = new DBHelp<Admin>();
	
	public Admin findByNameAndPwd(String name,String pwd) {
		String sql = "select id,name,password from t_admin where name = ? and password = ?";
		return db.executeQueryForObject(sql, new AdminRowMapper(), name,pwd);
	}
	private class AdminRowMapper implements RowMapper<Admin> {

		public Admin mapperRow(ResultSet rs) throws SQLException {
			Admin admin = new Admin();
			
			admin.setId(rs.getInt("id"));
			
			admin.setPassword(rs.getString("password"));
			admin.setName(rs.getString("name"));
			return admin;
		}
	}

}
